package ocean;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import ocean.chinacraft.client.ModRender;
import ocean.chinacraft.client.ModScreen;
import ocean.chinacraft.common.ModContainer;
import ocean.chinacraft.common.*;
import ocean.chinacraft.common.config.ApplicationConfig;
import ocean.chinacraft.common.constants.Constants;
import ocean.chinacraft.common.world.item.ModSounds;
import ocean.chinacraft.common.ModTileEntity;
import ocean.chinacraft.data.ModRecipeTypes;

/**
 * Main Class
 *
 * @author zhang
 * @since 2021/11/9
 **/
@Mod(value = Constants.MOD_ID)
public class OceanApplication {

    public OceanApplication() {
        MinecraftForge.EVENT_BUS.register(this);
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        ModEntityTypes.register(modEventBus);
        ModBlocks.register(modEventBus);
        ModItems.register(modEventBus);
        ModTileEntity.register(modEventBus);
        ModContainer.register(modEventBus);
        ModRecipeTypes.register(modEventBus);
        ModSounds.register(modEventBus);

        modEventBus.addListener(this::doClient);

        ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ApplicationConfig.SPEC, "china-craft.toml");
    }

    public void doClient(final FMLClientSetupEvent event) {
        ModScreen.screen();
        ModRender.renderTypeLook();
        ModEntity.entityRender();
    }
}
